Skip to content

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Jul 10, 2025

For WOOMOB-757

Just one review is required.

Description

This pull request introduces a new method refreshEligibility(ineligibleReason:) to POSEntryPointEligibilityCheckerProtocol with basic implementation in POSTabEligibilityChecker to handle eligibility state updates based on specific ineligible reasons. Site settings related cases and the POS feature switch disabled case are covered in this PR. Unsupported WC plugin version case will be supported separately in WOOMOB-799.

Eligibility refresh logic:

Protocol and implementation updates:

  • WooCommerce/Classes/ViewRelated/Dashboard/Settings/POS/POSTabEligibilityChecker.swift: Added the refreshEligibility method to the POSEntryPointEligibilityCheckerProtocol and implemented it in POSTabEligibilityChecker to handle various ineligible reasons, including syncing site settings remotely and checking eligibility again. checkEligibility currently just includes one API request to reload the POS feature switch value, the site settings and WC plugin values are synced outside of the eligibility checker from site initialization. [1] [2]

Error handling and site settings synchronization:

Legacy checker adjustments:

Steps to reproduce

Unsupported store currency

Prerequisite: for a store that is eligible for POS, change the currency in core under WC settings > General to a different value

  • Launch the app with the site in the prerequisite --> the POS tab should appear shortly
  • Tap on the POS tab --> after the loading state, an ineligible screen should be shown about the unsupported currency
  • Tap Retry --> the CTA should be in loading state, then back to normal state
  • In wp-admin, update the store currency to the supported value
  • Back in the app, tap Retry --> the CTA should be in loading state, then the app enters POS

POS feature switch disabled

Prerequisite: for a store that is eligible for POS and with WC version 10.0+, disable the POS feature in WooCommerce settings > Advanced > Features

  • Launch the app with the site in the prerequisite --> the POS tab should appear shortly
  • Tap on the POS tab --> after the loading state, an ineligible screen should be shown about the disabled POS feature
  • Tap Retry --> the CTA should be in loading state, then back to normal state
  • In wp-admin, enable the feature switch
  • Back in the app, tap Retry --> the CTA should be in loading state, then the app enters POS

Testing information

I tested the above cases, and when the device is offline.

Screenshots

Unsupported store currency

Simulator.Screen.Recording.-.iPad.A16.-.2025-07-10.at.15.15.40.mp4

POS feature switch disabled

Simulator.Screen.Recording.-.iPad.A16.-.2025-07-10.at.15.20.10.mp4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync changed the title Add refreshEligibility method to POSTabEligibilityChecker [POS as a tab i2] Refresh POS eligibility in ineligible UI: site settings and feature switch cases Jul 10, 2025
@jaclync jaclync changed the title [POS as a tab i2] Refresh POS eligibility in ineligible UI: site settings and feature switch cases [POS as a tab i2] Refresh POS eligibility in ineligible UI: site settings and feature switch disabled cases Jul 10, 2025
@jaclync jaclync added type: task An internally driven task. feature: POS labels Jul 10, 2025
@jaclync jaclync modified the milestones: 22.8, 22.9 Jul 10, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 10, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr15895-793a492
Version22.7
Bundle IDcom.automattic.alpha.woocommerce
Commit793a492
Installation URL32876tnf8rmt8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@joshheald joshheald self-assigned this Jul 11, 2025
Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well, 🚢 – thanks!

Comment on lines +269 to +285
func syncSiteSettingsRemotely() async throws {
try await withCheckedThrowingContinuation { [weak self] (continuation: CheckedContinuation<Void, Error>) in
guard let self else {
return continuation.resume(throwing: POSTabEligibilityCheckerError.selfDeallocated)
}
stores.dispatch(SettingAction.synchronizeGeneralSiteSettings(siteID: siteID) { [weak self] error in
guard let self else {
return continuation.resume(throwing: POSTabEligibilityCheckerError.selfDeallocated)
}
if let error {
return continuation.resume(throwing: error)
}
siteSettings.refresh()
continuation.resume(returning: ())
})
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we could/should start defining these sorts of things in Yosemite? It's not as good as full async, but better than potentially writing this much nested code more than once. The errors would have to be generic, and we might need to pass in stores, but that seems potentially OK?

Not thought this through particularly thoroughly though. There's a good chance we'd be better off investing time in making Yosemite more async friendly. Nothing to do in this PR 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. Definitely would be nice to create better interface in Yosemite for the POS use case, though sometimes there's already quite some logic in the Yosemite Store implementation. In general, I've been creating new APIs in Yosemite if it's something that doesn't exactly exist in a Yosemite Store. For something that's already available in a Yosemite Store, I still reuse it.

Would like to get your thought on the naming of the new APIs in Yosemite. WDYT about creating POS{Entity}Service for {Entity}Store in Yosemite? Currently, we have POSOrderService, POSReceiptService, POSEligibilityService behind their own protocol in Yosemite. I can make this change separately.

@jaclync
Copy link
Contributor Author

jaclync commented Jul 11, 2025

Merging this first to unblock other refresh behavior work, will likely make changes separately for #15895 (comment).

@jaclync jaclync merged commit 2eac0e1 into trunk Jul 11, 2025
15 checks passed
@jaclync jaclync deleted the feat/WOOMOB-757-refresh-eligibility branch July 11, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: POS type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants